/*  ------------------------------------------------------------------------  */
/*  Paper        : Does Stakeholder Outrage Determine Executive Pay?          */
/*  Program      : a02-06-salaryCutMain.do                                    */
/*  Description  : CEO compensation and salary cuts                           */
/*  ------------------------------------------------------------------------  */

/*  ------------------------------------  */

use "$temp112/outragePanel.dta", clear

xtset firm_id fyear
gen f2020_salary_cut1 = 2020.fyear#i1.dcut_all
	replace f2020_salary_cut1 = 0 if missing(f2020_salary_cut1)
tab fyear f2020_salary_cut1 if mainsample==1
tab fyear dcut_all if mainsample==1
gen f2021_salary_cut1 = l1.f2020_salary_cut1
	replace f2021_salary_cut1 = 0 if missing(f2021_salary_cut1)
tab fyear f2021_salary_cut1 if mainsample==1

gen f2019 = fyear==2019
gen f2020 = fyear==2020
gen f2021 = fyear==2021


gen firm_fe = 1
rename defer_rpt_as_comp_tot defer_rpt
rename defer_rpt_as_comp_tot_fr defer_rpt_fr

#delimit ;
global compvars
	tdc1 salary varcomp bonus stock_awards_fv option_awards_fv
	noneq_incent othcomp defer_rpt
; #delimit cr

foreach yvar in $compvars {
	winsor2 `yvar', cuts(.1 99.9) suffix(_w)
}

#delimit ;
local salaryCutMainDelta
	ln_mcap btm leverage_mkt tangibility ret_std roa_std xrd_at
	payout_d boardSize boardTenure prc_delta exret_202012 
; #delimit cr


cls
eststo drop *
foreach iter in first main {

di "----------------------"
di "Processing: `iter'"
di "----------------------"
local xvar ""
if inlist("`iter'","first") {
    local xvar f2020_salary_cut1 f2020
    local range 2019,2020
}
if inlist("`iter'","main") {
    local xvar f2020_salary_cut1 f2021_salary_cut1 f2020 f2021
    local range 2019,2021
}


foreach yvar in tdc1 salary bonus stock_awards_fv option_awards_fv noneq_incent othcomp defer_rpt {

local fix if inrange(fyear,`range') & mainsample==1, a(firm_id) vce(cluster firm_id)

eststo frcw_`iter'_`yvar': qui reghdfe `yvar'_fr `xvar' `salaryCutMainDelta' i.firm_fe `fix'

//  Absolute value regressions
capture drop `yvar'_wm
	gen `yvar'_wm = `yvar'_w / 1000
capture drop `yvar'_m
	gen `yvar'_m = `yvar' / 1000

eststo rwcw_`iter'_`yvar': qui reghdfe `yvar'_wm `xvar' ln_tdc1 i.firm_fe `salaryCutMainDelta' `fix'
eststo mwcw_`iter'_`yvar': qui reghdfe `yvar'_m `xvar' i.firm_fe `salaryCutMainDelta' `fix'

//  Remove TDC1 as control from first column
eststo rwcw_`iter'_tdc1: qui reghdfe tdc1_wm `xvar' i.firm_fe `salaryCutMainDelta' `fix'
eststo mwcw_`iter'_tdc1: qui reghdfe tdc1_m `xvar' i.firm_fe `salaryCutMainDelta' `fix'

}
}

/*  ------------------------------------------------------------------------  */
//  Show regressions


#delimit ;
global complayout
	, b(%8.3f) t(%8.3f) star(* 0.10 ** 0.05 *** 0.01) nonotes
	stats(r2_a N_full, layout(@ @) fmt(%8.3f %8.0fc)
	labels("Adjusted R2" "Observations")) indicate(	"Firm FE =  *firm_fe*")
; #delimit cr

eststo drop frcw_*_tdc1

// Robustness: CEO compensation in dollar terms subsequent to salary cuts
esttab mwcw_first_* $complayout nogap

// CEO compensation in dollar terms subsequent to salary cuts
eststo drop *defer*
esttab rwcw_first_* $complayout nogap

// CEO compensation components subsequent to salary cuts
esttab frcw_first_* $complayout nogap

// Value of CEO compensation subsequent to salary cuts (three-year sample)
esttab rwcw_main_* $complayout nogap

// CEO compensation components subsequent to salary cuts (three-year sample)
esttab frcw_main_* $complayout nogap

/*  -|----------------------------------------------------------------------  */
/*  ||  ---    Program end: a02-06-salaryCutMain.do                           */
/*  -|  ---    Attila Balogh    --------------------------------------------  */